import java.util.Random;
import java.util.Scanner;

public class Test {
    //private static int bound;
    //1编写程序数一下 1到 100 的所有整数中出现多少个数字9

    /*public static void main(String[] args) {
        int count=0 ;
for(int i=1;i<=100;i++){
    if(i%10==9){
        count++;
    }
    if(i/10==9){
        count++;
    }

}
        System.out.println(count);
    }*/


    //2计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值

   /* public static void main(String[] args) {
        double sum=0;
        for(int i=1;i<=100;i++){
            if(i%2!=0) {
                sum += 1.0 / i;
            }else {
            sum+= -1.0/i;
            }
            }
        System.out.println("sum="+sum);
        }*/

    //3猜数字完成猜数字游戏   ，用户输入数字，判断该数字是大于，小于，还是等于随机生成的数字，等于的时候退出程序
   /* public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        Random random=new Random();
        int ranNum=random.nextInt( 101);
        while(true){
            System.out.println("请输入要猜的数字");
            int num= scanner.nextInt();
            if(num<ranNum){
                System.out.println("猜小了");
            }else if(num>ranNum){
                System.out.println("猜大了");
            }else {
                System.out.println("猜对了");
                break;
            }
        }

    }*/



//4输入输出

public static void main(String[] args) {

//单组读入
    Scanner scan = new Scanner(System.in);
    /*System.out.println("请输入你的名字");
    String name = scan.nextLine();
    System.out.println("姓名"+name);
    System.out.println("请输入你的年龄");
    int age=scan.nextInt();
    System.out.println("年龄"+age);
    System.out.println("请输入你的工资");
    float salary= scan.nextFloat();
    System.out.println("工资"+salary);
    scan.close();*/
    //多组读入
  /*  while (scan.hasNext()){
        int age= scan.nextInt();
        System.out.println(age);
    }*/

    //5求两个数最大公约数
   /* int a = scan.nextInt();
    int b = scan.nextInt();
    int temp = 0;
    if (a < b) {
        temp = a;
        a = b;
        b = temp;
    }
    while (b!=0 ) {
        temp=a%b;
        a=b;
        b=temp;

    }
    System.out.println(a);*/


    //6输入一个整数的每一位

   /* int n= scan.nextInt();
    while(n!=0){
        System.out.print(n%10+" ");
        n/=10;
    }*/


    //7获取一个数二进制序列中所有的偶数位和奇数位， 分别输出二进制序列
   /* int num= scan.nextInt();
    System.out.println("奇数位：");
        for (int i =30; i >=0; i-=2) {
           int count= num >> i;
            System.out.print((count & 1 )+" ");

        }
    System.out.print("\n");
    System.out.println("偶数位：");
    for (int i = 31; i>0; i-=2) {
        int count=num >> i;
        System.out.print((count & 1 )+" ");

    }*/


    //模拟登录

    Random random=new Random();
    int ranNum=random.nextInt( 101);
    int count=3;
    while(count>0){
        System.out.println("请输入密码");
        int num= scan.nextInt();
        if(num==ranNum){
            System.out.println("登陆成功");
            break;
        }else{
            System.out.println("请重新登录");
        }
        count--;
    }
    System.out.println("退出程序");

    }

}











